from builtins import print as _print
from sys import _getframe


# 自定义print函数 方便输出时候带上行号
def print(*arg, **kw):
	s = f'第{_getframe(1).f_lineno}行：'  # 注此处需加参数 1。
	return _print(s, *arg, **kw)


# ### (1)算数运算符:  + - * / // % **

# +
var1 = 7
var2 = 90
res = var1 + var2
print(res)

# -
var1 = 7
var2 = 90
res = var1 - var2
print(res)

# *
var1 = 7
var2 = 10
res = var1 * var2
print(res)

# / 结果永远为小数
var1 = 10
var2 = 5
res = var1 / var2
print(res, type(res))

# // 地板除
"""被除数 ➗ 除数 = 商"""
"""注意点:结果只保留整数部分，如果被除数或者除数是小数,那么得到正常结果之后,数值后面带上.0变成小数"""
var1 = 5
var2 = 2.0
res = var1 // var2
print(res, type(res))

# %  取余
var1 = 7
var2 = 4
res = var1 % var2
print(res)
'''
求余计算中出现负数该怎么办？
(1)被除数为负，除数为正时，结果=[-(被除数和除数都为正值时的余数)]+除数
(1)被除数为正，除数为负时，结果=(被除数和除数都为正值时的余数)+除数
(3)被除数为负，除数为负时，结果=[-(被除数和除数都为正值时的余数)]
'''
res = -7 % 4  # -3 + 4 = 1
res = 7 % -4  # 3 + (-4) = -1
res = -7 % -4  # -3 (被除数和除数都是负的,正常结果加负号)
res = 81 % 7  # 4
res = 81 % -7  # -3
res = -81 % 7  # 3
res = -81 % -7  # -4
print(res)

# ** 幂运算
res = 2 ** 3
print(res)

# (2)比较运算符:  > < >= <= == !=
"""比较运算符的结果要么是True , 要么是False 只有两个值"""
res = 10 > 5
res = 10 >= 10
# ==这个符号是在做比较,比较==两边的数值是否一样
res = 5 == 9
res = 5 != 9
print(res)

# ### (3)赋值运算符:  = += -= *= /= //= %= **=
# = 赋值运算符 将右侧的值赋值给左侧变量
var1 = 10
var2 = 5
# +=
"""var1 = var1 + var2"""
var1 += var2
print(var1)

# -=
"""var1 = var1 - var2"""
var1 -= var2
print(var1)

# %=
"""var1 = var1 % var2"""
var1 %= var2
print(var1)

# (4)成员运算符:  in 和 not in (针对于容器型数据)
"""字符串判断时,必须是连续的片段"""
strvar = "今天天气要下雨,赶紧回家收衣服"

res = "今" in strvar
res = "天气" in strvar
res = "赶回" in strvar
print(res)

# 针对于列表,元组,集合
container = ["赵沈阳", "赵万里", "赵世超"]
container = ("赵沈阳", "赵万里", "赵世超")
container = {"赵沈阳", "赵万里", "赵世超"}
# res = "赵沈阳" in container
# res = "赵万里" not in container
res = "赵世超1223232" not in container
print(res)

# 针对于字典 (判断的是字典的键,不是值)
container = {"zsy": "赵沈阳", "zwl": "赵万里", "zsc": "赵世超"}
res = "赵沈阳" in container  # False
res = "zsy" in container
print(res)
